#include<iostream>
using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Solution {
public:
    ListNode* removeNthFromEnd(ListNode* head, int n) {
        ListNode *q = head, *p = head;
        for(int i = 0; i < n; i++){
        	if(p->next == NULL){
        		return head->next;
			}
        	p = p->next;
		}
		while(p->next != NULL){
			p = p->next;
			q = q->next;
		}
		ListNode* r = q->next;
		q->next = q->next->next;
		return head;
    }
};

int main(){
	return 0;
}
